package com.single.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.single.service.SingleService;

@Controller
@RequestMapping("/single")
public class SingleController {
	@Resource(name="singleService")
	private SingleService singleService;
	/**
	 * 单机每日电度电费统计
	 * @param equId
	 * @param belongDate
	 * @param response
	 * @return
	 */
	@RequestMapping("/singlereday")
	public Map<String, Object> singleRefreshData(@RequestParam(value="equId",required=false,defaultValue="0")int equId,
			String belongDate,HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		Map<String, Object> model=new HashMap<String, Object>();
		singleService.singleChargesByDay(equId, belongDate,model);
		return model;
	}
	/**
	 * 单机电度电费日综合统计
	 * @param equId
	 * @param startDate
	 * @param endDate
	 * @param model
	 */
	@RequestMapping("/singleredate")
	public Map<String, Object> singleredate(@RequestParam(value="equId",required=false,defaultValue="0")int equId,
			String startDate,String endDate,HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		Map<String, Object> model=new HashMap<String, Object>();
		singleService.singleChargesByDate(equId, startDate, endDate, model);
		return model;
	}
	/**
	 * 单机电度电费周统计
	 * @param equId
	 * @param belongYear
	 * @param startWeek
	 * @param endWeek
	 * @param endDate
	 * @param response
	 * @return
	 */
	@RequestMapping("/singlereweek")
	public Map<String, Object> singlereweek(@RequestParam(value="equId",required=false,defaultValue="0")int equId,
			int belongYear,int startWeek,int endWeek,HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		Map<String, Object> model=new HashMap<String, Object>();
		singleService.singleChargesByWeek(equId, belongYear, startWeek, endWeek, model);
		return model;
	}
    /**
     * 单机电度电费月统计
     * @param equId
     * @param startMonth
     * @param endMonth
     * @param response
     * @return
     */
	@RequestMapping("/singleremonth")
	public Map<String, Object> singleremonth(@RequestParam(value="equId",required=false,defaultValue="0")int equId,
			String startMonth,String endMonth,HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		Map<String, Object> model=new HashMap<String, Object>();
		singleService.singleChargesByMonth(equId, startMonth, endMonth, model);
		return model;
	}
}
